<!-- 加工单明细 -->
<template>
	<view>
		<div>
			<navitop>
				<i class="iconfont" slot="left-slot" @click="revert_upper">&#xe667;</i>
				<span slot="center-slot">{{titles}}</span>
				<!-- <i class="iconfont " slot="right-slot" @click="add">确定</i> -->
			</navitop>
		</div> 
		
		<div :style="'margin-top:' + nv_height">
			<mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption" >
				<view class="port" v-for="(item,index) in dataSorce" @click="portclick(item)">
					<div class="port_out">
						<div class='port_left'>编号：</div>
						<div class="port_right">{{item.code}}</div>
					</div>
					<div class="port_out">
						<div class='port_left'>名称：</div>
						<div class="port_right">{{item.name}}</div>
					</div>
					<div class="port_out">
						<div class='port_left'>状态：</div>
						<div class="port_right">{{item.status == 1 ? '启用': '禁用'}}</div>
					</div>
					<div class="port_out">
						<div class='port_left'>有效时间：</div>
						<div class="port_right">{{item.invalidDate}}</div>
					</div>
				</view>
			</mescroll-body>
		</div>
	</view>
</template>

<script>
	import navitop from '@/components/common/navi-top'	
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	import {listDetail} from '@/common/api/job/machining.js'
export default {
	components:{
		navitop
	},
	mixins: [MescrollMixin],
	data(){
		return {
			nv_height: '',
			titles:'工艺路线',
			dataSorce: [],
			uid: '',
			// 下拉刷新的配置
			downOption: {
				auto: false,
				beforeEndDelay: 300,
			},
			// 上拉加载的配置
			upOption: {
				auto: false,
				page: {
					size: 10 // 每页数据的数量,默认10
				},
				noMoreSize: 5, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
				empty: {
					use: true,
					tip: '暂无相关数据'
				},
				textNoMore: '没有更多数据了...',
				toTop: {
					offset: 1000 // 滚动多少才显示to-top 
				}
			},
		}
	},
	onLoad(option) {
		this.uid = option.id;
	},
	mounted() {
		 this.nv_height = uni.getSystemInfoSync().statusBarHeight + 75 + 'px';
		 this.font_list();
	},
	methods: {
		
		// 获取列表
		font_list(){
			listDetail({current: 1,size: -1}).then((rows) => {
				if(rows.code == 200){
					this.dataSorce = rows.data.records;
				}
			})
		},
		
		// 汇报跳转
		portclick(val){
			uni.showLoading({
				title: '加载中...'
			})
			uni.navigateTo({
				url: '/components/index-modules/Manufacturing/processCard?id=' + val.id 
			})
			setTimeout(()=> {
				uni.hideLoading();
				
			},1500)
			
		},
		
		// 返回上一页
		revert_upper(){
			// uni.navigateTo({
			// 	url: '/components/index-modules/Manufacturing/processing'
			// })
			uni.switchTab({
				url: '/pages/index/index'
			})
		},
		
		/*下拉刷新的回调*/
		downCallback(val) {
			console.log('下拉--------')
			this.font_list();
			// 下拉刷新和上拉加载调同样的接口,直接mescroll.resetUpScroll()即可
			setTimeout(() => {
				this.mescroll.endSuccess();
			}, 500)
		},
		
		// 上拉加载
		upCallback(page) {
			// this.pages++;
			// let sun = this.pages;
			// // let obj = {
			// // 	current: page.num, // 页码, 默认1
			// // 	size: page.size, // 页长, 默认10条
			// // };
			// this.office_list(this.tab_key,sun);
			// setTimeout(()=>{
			// 	this.mescroll.endErr();
			// },500)
		},
	}
}	
</script>

<style lang="scss" scoped>
	.port{
		width: 95%;
		margin: auto;
		background-color: #fff;
		border-radius: 4px;
		margin-top: 10px;
	}
	.port_out {
		display: flex;
		div {
			height: 60rpx;
			line-height: 60rpx;
		}
	}
	.port_left {
		width: 35%;
		text-align: right;
	}
</style>
